package com.zhongjianjian.elasticjob.mq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 作者: LCG
 * 日期: 2020/2/25 10:02
 * 描述:
 */
@Configuration
public class RebbaitMqConfig {


    public RebbaitMqConfig() {

        System.out.println("=======================");

    }

    @Bean("queue")
    public Queue getQueue(){
        return new Queue("TEST-TUISONG-QUEUE",true,false,false);
    }


    @Bean("exchange")
    public Exchange getExchange(){
        Exchange build = ExchangeBuilder.directExchange("TEST-TUISONG-EXCHANGE").durable(true).build();
        return build;
    }

    //绑定队列和交换器
    @Bean("binding")
    public Binding getBinding(Queue queue,Exchange exchange){
        Binding tuisong = BindingBuilder.bind(queue).to(exchange).with("TUISONG").noargs();
        return tuisong;
    }

}
